const AC_GameObjects = [];
export class ACGameObjects {
    constructor() {
        AC_GameObjects.push(this);
        this.timedelta = 0;
        this.has_called_start = false;
    }
    start() {

    }
    update() {

    }
    on_destroy() {

    }
    destroy() {
        this.on_destroy();
        for (let i in AC_GameObjects) {
            const obj = AC_GameObjects[i];
            if (obj === this) { AC_GameObjects.splice(i, 1); break; }

        }
    }
}
let last_time = 0;
const step = (timestamp) => {
    for (let obj of AC_GameObjects) {
        if (!obj.has_called_start) {
            obj.has_called_start = true;
            obj.start();
        }
        else {
            obj.timedelta = timestamp - last_time;

            obj.update();
        }
    }
    last_time = timestamp;
    requestAnimationFrame(step);
}
requestAnimationFrame(step)